<template>
  <div class="reservation">
    <div v-if="designerList && designerList.length">
      <div class="panel-reservatin" v-for="(item, index) of designerList" :key="index">
        <div class="left">
          <img v-if="item.designer.length" :src="item.designer[0].avatar" alt />
        </div>
        <div class="right">
          <div class="top">
            <div class="designer-name" v-if="item.designer.length">{{ item.designer[0].name }}</div>
            <div class="time">{{ item.created_at }}</div>
          </div>
          <div class="bottom">备注：{{item.message}}</div>
        </div>
      </div>
    </div>
    <no-result v-else :src="require('@/assets/images/1-wdhd.png')" msg="没有任何预约~" />
  </div>
</template>
<script>
import { getReservationList } from '@/api/my'
import NoResult from '@/components/no-result/no-result'
const ERR_OK = 200
export default {
  components: {
    NoResult
  },
  data () {
    return {
      designerList: null
    }
  },
  created () {
    this._getReservationList()
  },
  methods: {
    _getReservationList () {
      getReservationList()
        .then(res => {
          if (res.code === ERR_OK) {
            this.designerList = res.data
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.reservation {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  background: #f7f7f7;
  padding: 0.42rem 0.36rem 0 0.36rem;
  box-sizing: border-box;
  .panel-reservatin {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.34rem;
    box-sizing: border-box;
    background: #fff;
    margin-bottom: 0.3rem;
    .left {
      width: 0.96rem;
      height: 0.96rem;
      border-radius: 50%;
      margin-right: 0.37rem;
      img {
        width: 100%;
      }
    }
    .right {
      flex: 1;
      .top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .designer-name {
          font-size: 0.28rem;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(4, 0, 0, 1);
        }
        .time {
          font-size: 0.2rem;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(4, 0, 0, 1);
        }
      }
      .bottom {
        margin-top: 0.27rem;
        font-size: 0.2rem;
        font-family: PingFang SC;
        font-weight: 400;
        color: rgba(102, 102, 102, 1);
        line-height: 0.32rem;
      }
    }
  }
}
</style>
